package demo4_1.service;

import demo4_1.dao.IUserDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class UserServiceImpl implements IUserService{
    @Autowired
    private IUserDAO userDAO;

    @Override
    public boolean login(String username, String password) {
        boolean user = userDAO.findByUsername(username);
        if (user){
            if ("123456".equals(password)){
                System.out.println("UserService:登陆成功");
                return true;
            }else {
                System.out.println("UserService:密码错误");
                return false;
            }
        }else {
            System.out.println("UserService:用户名错误");
        }
        return false;
    }
}
